import { defineStore } from 'pinia'

export const useUserStore = defineStore('user', {
    state: () => ({
        token: '',
        userInfo: {
            id: '',
            username: '',
            role: ''
        }
    }),
    getters: {
        isLogin: (state) => {
            return state.token !== ''
        }
    },
    actions: {
        setToken(token) {
            this.token = token
        },
        setUserInfo(userInfo) {
            this.userInfo = userInfo
        }
    }
})